﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class SocialNetworkingMasterPage : System.Web.UI.MasterPage
{
    public string chuoi = "";
    private UsersBLL userBLL = new UsersBLL();
    private Users user;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] != null)
        {
            this.user = (Users)Session["User"];
        }
        else if (Session["Guest"] != null)
        {
            this.user = (Users)Session["Guest"];
        }

        if (user != null)
        {
            UserProfiles userProfile = this.userBLL.GetIUserProfiles.GetUserProfileOfUser(user);
            if (userProfile != null)
            {
                this.imgAvatar.ImageUrl = Constant.AVATAR_LOCATION + userProfile.Avatar;
                this.lblUsername.Text = userProfile.User.Username;
            }
            else
            {
                Response.Redirect("CreateUserProfiles.aspx");   
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
    protected void txtTim_TextChanged(object sender, EventArgs e)
    {
        Button1_Click(sender,e);
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
         Session["Username"] = txtSearchFriend.Text.Trim();
         Response.Redirect("ShowListUsers.aspx");
       
    }

    protected void lbLogOut_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Response.Redirect("Login.aspx");
    }
}
